package tree;

import java.util.List;

public class L104 {
    public static int maxDepth(TreeNode root) {
        int ld;
        int re;
        if (root==null){
            return 0;
        }else{
            ld=maxDepth(root.left);
            re=maxDepth(root.right);
            int maxDe=ld > re ?(ld+1):(re+1);
            return maxDe;
        }



    }
    public static void main(String[] args) {
        // 构造二叉树的节点
        TreeNode node6 = new TreeNode(6, null, null);
        TreeNode node7 = new TreeNode(7, null, null);
        TreeNode node9 = new TreeNode(9, null, null);
        TreeNode node8 = new TreeNode(8, node6, node7);
        TreeNode root = new TreeNode(3, node9, node8);

        // 假设printByLevels方法是你已经实现的
        int i = maxDepth(root);
        // 打印结果
        System.out.println(i);
    }




}
